const newsService = require("../service/newsService");
class newsController {
    // 创建新闻
    async create(ctx) {
        const result = await newsService.create(ctx.request.body);
        ctx.body = result;
    }
    // 删除新闻
    async remove(ctx) {
        const result = await newsService.delete(ctx.params.id);
        ctx.body = result;
    }
    // 更新新闻
    async update(ctx) {
        const result = await newsService.update(
            ctx.params.id,
            ctx.request.body
        );
        ctx.body = result;
    }

    // 查看新闻数据库单条数据
    async get(ctx) {
        const result = await newsService.get(ctx.params.id);
        ctx.body = result;
    }
    async getList(ctx) {
        const result = await newsService.getList(ctx.request.body);
        ctx.body = result;
    }
    async search(ctx) {
        // console.log(ctx.query)
        const { type } = ctx.query;
        // console.log('type', type)
        const result = await newsService.search(type);
        ctx.body = result

    }

}
module.exports = new newsController